home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
SMALLTAL
/
SMALLT
< prev
next >
Wrap
Text File
|
1989-02-09
|
11KB
|
381 lines
"
This file contains fixes to the following Smalltalk/V Mac bugs:
PRINTING
- ImageWriter printers don't print.
- lines containing only a single CR don't print (this bug also causes
early termination of printing when the last line on a page is blank).
- on a standard size page, the last line of output is clipped at
the bottom of the page.
- when a line must be wrapped to fit the width of a page, the
last character of the line is lost.
- the contents of a TextPane is always printed with the default font
rather than the font actually in the TextPane.
SCREEN
- with multiple monitors, Smalltalk/V Mac opens very large window
across all available screens; grey area not restored on leaving
application.
****** Note: this file will file in OK on either Smalltalk/V Mac
or Smalltalk/V Mac 68000.
"!
!MTrap class methods !
PrPicFile: hPrint pPrPort: pPrPort pIOBuf: pIOBuf pDevBuf: pDevBuf prStatus: prStatus
"Printing Manager.
Print the spooled copy of the document.
WARNING: prStatus passed in as pointer but defined
as record*. Look at the sender of this method
to see how this was done.
(Inside Macintosh II-160)"
<trap: stack long 16rA8FD handle pointer pointer pointer pointer 16r1480 16r6005>
^ self trapFailed! !
MType subclass: #TPrint
instanceVariableNames: ''
classVariableNames:
'THPrint PrintStatus'
poolDictionaries: ''!
!TPrint class methods !
statusBuffer
"Answer a buffer to use for holding the printer status
information."
PrintStatus isNil ifTrue: [
PrintStatus := MPointer new: 26.
].
^ PrintStatus
! !
!TPrint class methods !
invalidate
"Close and Nil out the THPrint."
THPrint isNil ifFalse: [
MTrap PrClose.
THPrint := nil
].
PrintStatus isNil ifFalse: [
PrintStatus dispose.
PrintStatus := nil.
].
! !
!TPrint class methods !
printSpooledDocument
"Cause the spooled document to be printed."
self validate.
THPrint spooling ifTrue: [
MTrap PrPicFile: THPrint asParameter
pPrPort: nil asParameter
pIOBuf: nil asParameter
pDevBuf: nil asParameter
prStatus: self statusBuffer asParameter
]
! !
!MTrap class methods !
TextSize: n
"QuickDraw.
Set the text point size.
(Inside Macintosh I-171)"
<trap: stack procedure 16rA88A integer>
^ self trapFailed! !
!PrintStream methods !
close
"Close the current page and the document."
port closePage ifFalse: [
self error: 'error in printing'.
].
port closeDocument ifFalse: [
self error: 'error in printing'.
].
TPrint printSpooledDocument
! !
!PrintStream methods !
printCurrentLine
"Print the current line on the printer."
column ~= 1 ifTrue: [
line byteAtOffset: 0 put: column - 1.
Process enableInterrupts: false.
GrafPort pushTo: port.
self position: 1 @ row.
MTrap DrawString: line asParameter.
GrafPort pop.
Process enableInterrupts: true.
].
row = pageHeight ifTrue: [ ^ self newPage ].
column := 1.
row := row + 1.
! !
!PrintStream methods !
nextPut: aCharacter
"Write anObject to the receiver stream. Answer anObject."
aCharacter = Cr
ifTrue: [ ^ self printCurrentLine ].
aCharacter = Ff
ifTrue: [ ^ self newPage ].
line byteAtOffset: column put: aCharacter asciiValue.
column := column + 1.
column = pageWidth
ifTrue: [ ^ self printCurrentLine ].
^ aCharacter
! !
!PrintStream methods !
initialize: aTPrPort
"Initialize the instance variables of the receiver
using the aTPrPort and the current TPrint record."
| size |
port := aTPrPort.
port penNormal.
pageNumber := 1.
self font: (MacFont fontName: 'Monaco' pointSize: 12).
size := TPrint current pageSize.
pageWidth := (size x // (font width / 72) min: 255) - 1.
pageHeight := size y // (font height / 72) - 1.
row := 1.
column := 1.
line := Str255 newRecord.
port openPage.
! !
!PrintStream class methods !
on: aTPrPort using: aFont
"Answer a new instance of the receiver which
which will print on aTPrPort."
^ self new initialize: aTPrPort using: aFont! !
!PrintStream methods !
initialize: aTPrPort using: aFont
"Initialize the instance variables of the receiver
using the aTPrPort and the current TPrint record."
| size |
port := aTPrPort.
port penNormal.
pageNumber := 1.
self font: aFont.
size := TPrint current pageSize.
pageWidth := 255.
pageHeight := size y // (font height / 72).
row := 1.
column := 1.
line := Str255 newRecord.
port openPage.!
font: aFont
"Set the font to use for printing to aFont."
aFont isMacFont ifFalse: [
self error: 'Font must be a MacFont'].
font := aFont.
Process enableInterrupts: false.
GrafPort pushTo: port.
MTrap
TextFont: font glyphs;
TextSize: font pointSize.
GrafPort pop.
Process enableInterrupts: true.! !
!TextPane methods !
print
"Print the contents of the receiver."
| port printStream |
(port := TPrint print) isNil ifTrue: [ ^ self ].
printStream := PrintStream on: port using: curFont.
CursorManager execute change.
textHolder lines do: [ :line |
printStream nextPutAll: line; cr.
].
printStream close.
CursorManager normal change! !
" *** This fix for multiple monitors works ONLY for Finder. It's
OK to file in even if you use MultiFinder, but doesn't fix the
problem."!
!MTrap class methods !
InitWindows
"Window Manager.
Initialize the window system.
(Inside Macintosh I-281)"
<trap: stack procedure 16rA912>
^ self trapFailed! !
!SystemDictionary methods !
startUp
"Initiate a Smalltalk/ V session by filing in the' go'
file. This message is sent by the virtual machine."
| sourceDirectory |
"Set up the display screen."
MTrap InitWindows.
ScreenPort := Window windowManagerPort.
DisplayScreen Mac.
"Force any menus in the image which may be added
to the menu bar to be properly initialized."
MenuBar message: 'Initializing╔'.
Menu startUp: false.
"If go file specified, then file it in. If the
sources or changes files are unspecified afterwards,
file them in with the defaults."
Sources := Array new: 2.
sourceDirectory := Directory current.
Smalltalk openChangeLog: sourceDirectory.
Disk := (Sources at: 2) file directory.
(Disk hasFileNamed: 'go')
ifTrue: [ (Disk file: 'go') fileIn; close ].
(Sources at: 1) isNil
ifTrue: [ Sources at: 1 put: (sourceDirectory file: 'V.source') ].
"Do any other required system initialization."
Time initialize.
CompiledMethod initializeUserPrimitives.
Smalltalk openFilesFromDeskTop.
MenuBar clear.
Process enableInterrupts: true.
Scheduler resume
! !
" The following method causes windows to be opened on the main screen."!
!TopDispatcher class methods !
nextFrame
"Answer a screen rectangle (global coordinates) in
which to stack the next window."
| aPoint mainWindowFrame |
OpenPoint := OpenPoint isNil ifTrue: [ 0 ]
ifFalse: [ OpenPoint + 1 ].
OpenPoint > 20
ifTrue: [ OpenPoint := 0 ].
aPoint :=
((5 @ 18) * (OpenPoint \\ 5)) +
((27 @ -2) * (OpenPoint // 5)) +
(35 @ 50).
mainWindowFrame := ScreenPort screenRect.
^ aPoint + mainWindowFrame origin
corner:
aPoint + (mainWindowFrame corner * 3 // 4)
! !
" The following method assures that menu bar messages
are displayed on the screen that has the menu bar."!
!MenuBar class methods !
message: aString
"Display a message in the menu bar."
| rect |
MTrap ClearMenuBar; DrawMenuBar.
aString displayAt: 10 @ 2 + Screen boundingBox origin negated
font: Font menuFont
dest: Screen
! !
!GlobalDisplayScreen methods !
boundingBox
"Answer a Rectangle which bounds the receiver."
| answer |
answer := Region GrayRgn boundingBox.
answer origin y: (answer origin y min: 0).
^ answer
! !
"The following code causes error notifiers to pop up centered
on your main screen."!
!Debugger methods !
walkbackFor: aProcess label: aString
"Pop-up a walkback window with label equal to aString).
Display the stacked message sends for the receiver in
the window."
| recursing extent logger listLineHeight aTopPane |
process := aProcess.
recursing := RecursionInError.
maxLevel := 10.
RecursionInError
ifTrue: [
logger := Terminal.
logger cr; nextPutAll: 'error: ',aString; cr]
ifFalse: [
RecursionInError := true.
logger := WriteStream on: (String new: 40).
].
aProcess walkbackOn: logger maxLevels: maxLevel.
RecursionInError := false.
Process enableInterrupts: true.
recursing ifTrue: [
^ Smalltalk exit: false
] ifFalse: [
extent := ((350 max:
(LabelFont stringWidth: aString) + 40) min:
ScreenPort screenRect width - 20)
@ 250.
label := aString.
listLineHeight := Font menuFont height + 8.
aTopPane := TopPane new.
aTopPane
label: label;
model: self;
menu: #walkbackMenu;
minimumSize: 200@100;
addSubpane:
(TextPane new
model: logger contents;
framingBlock: [ :box |
box origin + (0 @ listLineHeight)
corner: box corner
]).
aTopPane addSubpane:
(ButtonPane new
model: self;
buttons: #(Resume Debug);
framingBlock: [ :box |
box origin corner: box width @ listLineHeight
];
pulse: true).
aTopPane dispatcher
openIn: (ScreenPort screenRect extent // 2
- (extent // 2)
extent: extent);
scheduleWindow.
Scheduler run
]
! !